<template>
  <a-card :bordered="false">
    <div class="table-page-search-wrapper" v-if="showSearch==true">
      <a-form layout="inline">
        <a-row :gutter="48">
				  <a-col :md="5" :sm="15">
					<a-form-item :label="i18n('form.categoryId','分类ID')">
                        <a-input :placeholder="i18n('form.categoryId','分类ID','input')" v-model="queryParam.Q_TYPE_ID__S_LK"/>
					</a-form-item>
				  </a-col>
				  <a-col :md="5" :sm="15">
					<a-form-item :label="i18n('form.filename','文件名')">
                        <a-input :placeholder="i18n('form.filename','文件名','input')" v-model="queryParam.Q_FILE_NAME__S_LK"/>
					</a-form-item>
				  </a-col>
				  <a-col :md="5" :sm="15">
					<a-form-item :label="i18n('form.filenameNew','新文件名')">
                        <a-input :placeholder="i18n('form.filenameNew','新文件名','input')" v-model="queryParam.Q_NEW_FNAME__S_LK"/>
					</a-form-item>
				  </a-col>
				  <a-col :md="5" :sm="15">
					<a-form-item :label="i18n('form.filePath','文件路径')">
                        <a-input :placeholder="i18n('form.filePath','文件路径','input')" v-model="queryParam.Q_PATH__S_LK"/>
					</a-form-item>
				  </a-col>
				  <a-col :md="5" :sm="15">
					<a-form-item :label="i18n('form.varchar','图片缩略图')">
                        <a-input :placeholder="i18n('form.varchar','图片缩略图','input')" v-model="queryParam.Q_THUMBNAIL__S_LK"/>
					</a-form-item>
				  </a-col>
				  <a-col :md="5" :sm="15">
					<a-form-item :label="i18n('form.extension','扩展名')">
                        <a-input :placeholder="i18n('form.extension','扩展名','input')" v-model="queryParam.Q_EXT__S_LK"/>
					</a-form-item>
				  </a-col>
				  <a-col :md="5" :sm="15">
					<a-form-item :label="i18n('form.typeAttachment','附件类型')">
                        <a-input :placeholder="i18n('form.typeAttachment','附件类型','input')" v-model="queryParam.Q_MINE_TYPE__S_LK"/>
					</a-form-item>
				  </a-col>
				  <a-col :md="5" :sm="15">
					<a-form-item :label="i18n('form.description','说明')">
                        <a-input :placeholder="i18n('form.description','说明','input')" v-model="queryParam.Q_DESC__S_LK"/>
					</a-form-item>
				  </a-col>
				  <a-col :md="5" :sm="15">
					<a-form-item :label="i18n('form.bytes','总字节数')">
                        <a-input-number :min="0" :max="1000000" :placeholder="i18n('form.bytes','总字节数','input')" v-model="queryParam.Q_TOTAL_BYTES__I_EQ"/>
					</a-form-item>
				  </a-col>
				  <a-col :md="5" :sm="15">
					<a-form-item :label="i18n('form.identity','删除标识')">
                        <a-input :placeholder="i18n('form.identity','删除标识','input')" v-model="queryParam.Q_DEL_STATUS__S_LK"/>
					</a-form-item>
				  </a-col>
				  <a-col :md="5" :sm="15">
					<a-form-item :label="i18n('form.module','模块ID')">
                        <a-input :placeholder="i18n('form.module','模块ID','input')" v-model="queryParam.Q_MODULE_ID__S_LK"/>
					</a-form-item>
				  </a-col>
				  <a-col :md="5" :sm="15">
					<a-form-item :label="i18n('form.record','记录ID')">
                        <a-input :placeholder="i18n('form.record','记录ID','input')" v-model="queryParam.Q_RECORD_ID__S_LK"/>
					</a-form-item>
				  </a-col>
				  <a-col :md="5" :sm="15">
					<a-form-item :label="i18n('form.type','来源类型')">
                        <a-input :placeholder="i18n('form.type','来源类型','input')" v-model="queryParam.Q_FROM__S_LK"/>
					</a-form-item>
				  </a-col>
				  <a-col :md="5" :sm="15">
					<a-form-item :label="i18n('form.status','生成PDF状态')">
                        <a-input :placeholder="i18n('form.status','生成PDF状态','input')" v-model="queryParam.Q_COVER_STATUS__S_LK"/>
					</a-form-item>
				  </a-col>
				  <a-col :md="5" :sm="15">
					<a-form-item :label="i18n('form.system','文件系统')">
                        <a-input :placeholder="i18n('form.system','文件系统','input')" v-model="queryParam.Q_FILE_SYSTEM__S_LK"/>
					</a-form-item>
				  </a-col>
				  <a-col :md="5" :sm="15">
					<a-form-item :label="i18n('form.path','PDF文件路径')">
                        <a-input :placeholder="i18n('form.path','PDF文件路径','input')" v-model="queryParam.Q_PDF_PATH__S_LK"/>
					</a-form-item>
				  </a-col>
		  <template v-if="advanced">
			<!--TODO add advance search field here -->
          </template>

          <a-col :md="8" :sm="24">
            <span class="table-page-search-submitButtons">
              <a-button type="primary" @click="$refs.table.refresh(true)" icon="search">
                  {{$ti18('rxList.searchBtn','查询')}}
              </a-button>
              <a-button style="margin-left: 4px" @click="resetSearch">
                   {{$ti18('rxList.resetBtn','重置')}}
              </a-button>
              <a @click="toggleAdvanced" style="margin-left: 8px">
                  {{ advanced ? $ti18('rxList.putAwayBtn','收起') : $ti18('rxList.openBtn','收起') }}
                  <a-icon :type="advanced ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <div class="table-operator">
      <a-button  type="primary" icon="plus" @click="add">
          {{$ti18('rxList.newBtn',"新建")}}
      </a-button>
      <a-button v-if="editEnable && selectedRowKeys.length > 0" type="primary" icon="edit" @click="editOne">
          {{$ti18('rxList.editBtn','编辑')}}
      </a-button>
      <a-dropdown v-if="removeEnable && selectedRowKeys.length > 0">
        <a-button type="danger" icon="delete" @click="delByIds(selectedRowKeys)">
            {{$ti18('rxList.delBtn','删除')}}
        </a-button>
      </a-dropdown>
      <span style="float:right">
         <a-button type="primary" shape="circle"  icon="sync" :size="small" @click="refreshGrid"></a-button>
         <a-button type="primary" shape="circle"  icon="search" :size="small" @click="toggleSearch"></a-button>
       </span>
    </div>
    <s-table
      size="default"
      ref="table"
      rowKey="fileId"
      :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
      :columns="columns"
      :data="loadData">
	 <span slot="serial" slot-scope="text, record, index">
		{{ index + 1 }}
	 </span>
      <span slot="action" slot-scope="text, record" class="actionIcons">
        <span v-if="editEnable" @click="edit(record)">
             {{$ti18('rxList.editBtn','编辑')}}
        </span>
        <span v-if="removeEnable" @click="delByIds([record.fileId])">
             {{$ti18('rxList.delBtn','删除')}}
        </span>
      </span>
    </s-table>
    <sysFile-edit ref="modal" @ok="handleOk"/>
  </a-card>
</template>

<script>
  import SysFileApi from '@/api/system/core/sysFile'
  import SysFileEdit from './SysFileEdit'
  import {BaseList} from "@lowcode/jpaas-common-lib";
  export default {
    name: 'SysFileList',
    mixins:[BaseList],
    data () {
      return {
        columns: [
          {title: '#',scopedSlots: { customRender: 'serial' },width: 30},
          { title: this.i18n('form.categoryId','分类ID'),dataIndex: 'typeId',width: 120 },
          { title: this.i18n('form.filename','文件名'),dataIndex: 'fileName',width: 120 },
          { title: this.i18n('form.filenameNew','新文件名'),dataIndex: 'newFname',width: 120 },
          { title: this.i18n('form.filePath','文件路径'),dataIndex: 'path',width: 120 },
          { title: this.i18n('form.varchar','图片缩略图'),dataIndex: 'thumbnail',width: 120 },
          { title: this.i18n('form.extension','扩展名'),dataIndex: 'ext',width: 120 },
          { title: this.i18n('form.typeAttachment','附件类型'),dataIndex: 'mineType',width: 120 },
          { title: this.i18n('form.description','说明'),dataIndex: 'desc',width: 120 },
          { title: this.i18n('form.bytes','总字节数'),dataIndex: 'totalBytes',width: 120 },
          { title: this.i18n('form.identity','删除标识'),dataIndex: 'delStatus',width: 120 },
          { title: this.i18n('form.module','模块ID'),dataIndex: 'moduleId',width: 120 },
          { title: this.i18n('form.record','记录ID'),dataIndex: 'recordId',width: 120 },
          { title: this.i18n('form.type','来源类型'),dataIndex: 'from',width: 120 },
          { title: this.i18n('form.status','生成PDF状态'),dataIndex: 'coverStatus',width: 120 },
          { title: this.i18n('form.system','文件系统'),dataIndex: 'fileSystem',width: 120 },
          { title: this.i18n('form.path','PDF文件路径'),dataIndex: 'pdfPath',width: 120 },
          {title: this.$ti18('rxList.action','操作'), width: '220px', dataIndex: 'action', scopedSlots: {customRender: 'action'}}
        ],
        component:SysFileEdit,
        comment:this.i18n('list.accessories','系统附件'),
        widthHeight:['800px','600px']
      }
    },
    methods:{
        i18n(name,text,key){
            return this.$ti18(name,text,"SysFile",key);
        },
      delById(ids){
        return SysFileApi.del({ ids: ids.join(',') });
      },
      getListByParams(parameter){
        return SysFileApi.query(parameter)
      }
    }
  }
</script>
<style scoped>

</style>

